home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / machack / Hacks97 / WarriorsProgress.sit / Warrior’s Progress / source code / Source / Libraries / Proxies / SimpleProxy.h < prev    next >
Text File  |  1997-06-28  |  820b  |  49 lines

  1. // SimpleProxy.h
  2.  
  3. #ifndef SimpleProxy_h
  4. #define SimpleProxy_h
  5.  
  6. #ifndef Proxy_h
  7. #include "Proxy.h"
  8. #endif
  9. #ifndef Assert_h
  10. #include "Assert.h"
  11. #endif
  12.  
  13. template < class OwnerType, class StoodFor >
  14. class SimpleProxy: public Proxy< StoodFor >
  15.   {
  16.     typedef OwnerType Owner;
  17.     typedef StoodFor (Owner::*Getter)() const;
  18.     typedef void (Owner::*Setter)( StoodFor ) const;
  19.     
  20.     private:
  21.         const Owner& owner;
  22.         const Getter get;
  23.         const Setter set;
  24.     
  25.     public:
  26.         SimpleProxy( const Owner& theOwner,
  27.                          Getter getter,
  28.                          Setter setter )
  29.           : owner( theOwner ),
  30.              get( getter ),
  31.              set( setter )
  32.           {
  33.             Assert( getter != 0 );
  34.             Assert( setter != 0 );
  35.           }
  36.         
  37.         virtual StoodFor Get() const
  38.           {
  39.             return (owner.*get)();
  40.           }
  41.         
  42.         virtual void Set( StoodFor value )
  43.           {
  44.             (owner.*set)( value );
  45.           }
  46.   };
  47.  
  48. #endif
  49.